{% extends 'base.html' %}
{% load widget_tweaks %}
{% load tz %}
{% load widget_tweaks %}

{% block content %}
<div class="container mt-4">
    {% if messages %}
        {% for message in messages %}
            <div class="alert alert-{{ message.tags }} alert-dismissible fade show" role="alert">
                {{ message }}
                <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="关闭"></button>
            </div>
        {% endfor %}
    {% endif %}
    <h2>{% if object %}编辑{% else %}新增{% endif %}表彰记录</h2>
    <form method="post">
        {% csrf_token %}
        <div class="mb-3">
    {{ form.student.label_tag }}
    {{ form.student|add_class:'form-control'|attr:'required' }}
    {% if form.student.errors %}
        <div class="invalid-feedback d-block">{{ form.student.errors|join:', ' }}</div>
    {% endif %}
</div>
<div class="mb-3">
    {{ form.honor_type.label_tag }}
    {{ form.honor_type|add_class:'form-control'|attr:'required' }}
    {% if form.honor_type.errors %}
        <div class="invalid-feedback d-block">{{ form.honor_type.errors|join:', ' }}</div>
    {% endif %}
</div>
<div class="mb-3">
    {{ form.award_date.label_tag }}
    {{ form.award_date|add_class:'form-control'|attr:'type:date'|attr:"value:{% now 'Y-m-d' %}" }}
    {% if form.awarded_date.errors %}
        <div class="invalid-feedback d-block">{{ form.awarded_date.errors|join:', ' }}</div>
    {% endif %}
</div>
<div class="mb-3">
    {{ form.title.label_tag }}
    {{ form.title|add_class:'form-control'|attr:'required' }}
    {% if form.title.errors %}
        <div class="invalid-feedback d-block">{{ form.title.errors|join:', ' }}</div>
    {% endif %}
</div>
<div class="mb-3">
    {{ form.award_organizer.label_tag }}
    {{ form.award_organizer|add_class:'form-control'|attr:'required' }}
    {% if form.award_organizer.errors %}
        <div class="invalid-feedback d-block">{{ form.award_organizer.errors|join:', ' }}</div>
    {% endif %}
</div>
<div class="mb-3">
    {{ form.description.label_tag }}
    {{ form.description|add_class:'form-control'|attr:'rows:3' }}
    {% if form.description.errors %}
        <div class="invalid-feedback d-block">{{ form.description.errors|join:', ' }}</div>
    {% endif %}
</div>
        <button type="submit" class="btn btn-primary">保存</button>
        <a href="{% url 'core:honor_record_list' %}" class="btn btn-secondary">取消</a>
    </form>
</div>
{% endblock %}
